//
//  ListViewController.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/25.
//

#import "ListViewController.h"
#import "CommonUtil.h"
#import "PersonDetailViewController.h"
#import "PingTeViewController.h"
#import "ShareSortViewController.h"
#import "MRTHomeViewController.h"
#import "ChallengeViewController.h"
#import "BigStoryViewController.h"
#import "GangCaiViewController.h"
#import "ActivityCenterViewController.h"
#import "ShareViewController.h"


@interface ListViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView * tableView;
@property (strong, nonatomic) NSArray * datas;
@end

@implementation ListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"test";
    self.datas = @[@"统计",@"高手论坛",@"购买小红花",@"添加好友",@"红包打赏",@"名人堂留言板",@"港彩名人堂-平特",@"分享排行榜",@"粉丝排行榜",@"贡献榜",@"魅力榜",@"名人堂首页",@"用户主页",@"挑战",@"猛料市场",@"六合图库",@"港彩名人堂",@"活动中心",@"多页分享",@"跑狗玄机",@"幽默猜测",@"四不像"];
    
    [self.view addSubview:self.tableView];
    
    
}




#pragma mark - UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.datas.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text = self.datas[indexPath.row];
    return cell;
}

#pragma mark - UITableViewDelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *title = self.datas[indexPath.row];
    if ([title isEqualToString:@"购买小红花"]) {
        BaseAlert *alert = [HudFactory creatHudWithType:@"BuyRedFlower"];
        [alert show];
    }else if ([title isEqualToString:@"添加好友"]){
        BaseAlert *alert = [HudFactory creatHudWithType:@"AddFriendAlert"];
        [alert show];
    }else if ([title isEqualToString:@"红包打赏"]){
        BaseAlert *alert = [HudFactory creatHudWithType:@"rewardMoneyAlert"];
        [alert show];
    }else if ([title isEqualToString:@"名人堂留言板"]){
        [self.navigationController pushViewController:[PersonDetailViewController new] animated:YES];
    }else if ([title isEqualToString:@"港彩名人堂-平特"]){
        [self.navigationController pushViewController:[PingTeViewController new] animated:YES];
    }else if ([title isEqualToString:@"分享排行榜"] ||
              [title isEqualToString:@"粉丝排行榜"]||
              [title isEqualToString:@"贡献榜"]||
              [title isEqualToString:@"魅力榜"] ){
        
        ShareSortViewController *vc = [[ShareSortViewController alloc] init];
        if ([title isEqualToString:@"分享排行榜"]) {
            vc.sortMode = ShareSortShare;
        }else if ([title isEqualToString:@"粉丝排行榜"]){
            vc.sortMode = ShareSortLiked;
        }else if ([title isEqualToString:@"贡献榜"]){
            vc.sortMode = ShareSortContribution;
        }else if ([title isEqualToString:@"魅力榜"]){
            vc.sortMode = ShareSortCharm;
        }
        
        [self.navigationController pushViewController:vc animated:YES];
    }else if ([title isEqualToString:@"名人堂首页"]){
        [self presentViewController:[MRTHomeViewController new] animated:YES completion:nil];
    }else if ([title isEqualToString:@"用户主页"]){
        ForumViewController *vc = [ForumViewController new];
        vc.type = PageTypeHomePage;
        [self.navigationController pushViewController:vc animated:YES];
    }else if ([title isEqualToString:@"统计"]){
        [self.navigationController pushViewController:[StatisticsViewController new] animated:YES];
    }else if ([title isEqualToString:@"高手论坛"]){
        ForumViewController *vc = [ForumViewController new];
        vc.type = PageTypeForum;
        [self.navigationController pushViewController:vc animated:YES];
    }else if ([title isEqualToString:@"挑战"]){
        [self.navigationController pushViewController:[ChallengeViewController new] animated:YES];
    }else if ([title isEqualToString:@"猛料市场"]){
        BigStoryViewController *bigstore = [BigStoryViewController new];
        bigstore.type = DetailPageTypeBigStory;
        [self.navigationController pushViewController:bigstore animated:YES];
    }else if ([title isEqualToString:@"六合图库"]){
        BigStoryViewController *bigstore = [BigStoryViewController new];
        bigstore.type = DetailPageTypeGallery;
        [self.navigationController pushViewController:bigstore animated:YES];
    }else if ([title isEqualToString:@"港彩名人堂"]){
        [self.navigationController pushViewController:[GangCaiViewController new] animated:YES];
    }else if ([title isEqualToString:@"活动中心"]){
        [self.navigationController pushViewController:[ActivityCenterViewController new] animated:YES];
    }else if ([title isEqualToString:@"多页分享"]){
        [self.navigationController pushViewController:[ShareViewController new] animated:YES];
    }else if ([title isEqualToString:@"跑狗玄机"]){
        BigStoryViewController *bigstore = [BigStoryViewController new];
        bigstore.type = DetailPageTypeDog;
        [self.navigationController pushViewController:bigstore animated:YES];
    }else if ([title isEqualToString:@"幽默猜测"]){
        BigStoryViewController *bigstore = [BigStoryViewController new];
        bigstore.type = DetailPageTypeHumor;
        [self.navigationController pushViewController:bigstore animated:YES];
    }else if ([title isEqualToString:@"四不像"]){
        BigStoryViewController *bigstore = [BigStoryViewController new];
        bigstore.type = DetailPageTypeNorFowl;
        [self.navigationController pushViewController:bigstore animated:YES];
    }
    
    
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return AD(40);
}


-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.contentInset = UIEdgeInsetsMake(0, 0, AD(100), 0);
    }
    return _tableView;
}

@end
